package com.des1gn.server.businessimpl;

import com.des1gn.api.service.BusinessRetryService;
import com.des1gn.redis.StringRedisClient;
import com.des1gn.retry.RetryClass;
import com.des1gn.retry.RetryEnable;
import com.rrtv.rpc.server.annotation.RpcService;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

/**
 * @ClassName BusinessRetryServiceImpl
 * @Description TODO
 * @Author Des1gn
 * @Version 1.0
 **/
@Slf4j
@RetryClass(version = "1.0")
@RpcService(interfaceType = BusinessRetryService.class, version = "1.0")
public class BusinessRetryServiceImpl implements BusinessRetryService {

    @Resource
    StringRedisClient stringRedisClient;

    private static final String TEST_CACHE_KEY = "test.cache.key";

    @Override
    @RetryEnable
    public String getResult(String param) {
        String s = stringRedisClient.get(TEST_CACHE_KEY);
        if (s == null){
            throw new NullPointerException();
        }
        return s;
    }
}
